package com.bot.backend.controller.pk;

import com.bot.backend.service.pk.ReceiveSnakeMoveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

@RestController
public class ReceiveSnakeMoveController {
    @Autowired
    private ReceiveSnakeMoveService receiveSnakeMoveService;

    @PostMapping("/pk/receive/snake/move/")
    public String reveiveSnakeMove(@RequestParam MultiValueMap<String, String> data) {
        int user_id = Integer.parseInt(Objects.requireNonNull(data.getFirst("user_id")));
        int direction = Integer.parseInt(Objects.requireNonNull(data.getFirst("direction")));
        return receiveSnakeMoveService.receiveSnakeMove(user_id, direction);
    }
}
